﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace _2DGame
{
    class spelmeny
    {
      

        
        
        // constuctor for storing textures.
        Texture2D _startaspelettexture, _insttexture, _highscoretexture, _avslutaspeltexture, _bakgrundbtntxt;
        Vector2 _startaspeletpos, _instpos, _highscorepos, _avslutaspelpos, _bakgrundbtnpos;

        public spelmeny(Texture2D startaspelet, Vector2 startaspeletpos, Texture2D menyins, Vector2 menyinspos, Texture2D highscoretexture, Vector2 highscorepos, Texture2D avslutaspeltexture, Vector2 avslutaspelpos, Texture2D bakgrundbtntxt, Vector2 bakgrundbtnpos)
        {
            // give values to our variables, each button have its own pic, while the rest of the background is one pic.
            _startaspelettexture = startaspelet;
            _startaspeletpos = startaspeletpos;
            _insttexture = menyins;
            _instpos = menyinspos;
            _highscoretexture = highscoretexture;
            _highscorepos = highscorepos;
            _avslutaspeltexture = avslutaspeltexture;
            _avslutaspelpos = avslutaspelpos;
            _bakgrundbtntxt = bakgrundbtntxt;
            _bakgrundbtnpos = bakgrundbtnpos;

        }

        public void Draw(SpriteBatch spriteBatch)
        {

            //draw all pictures, background first, followed by the buttons
            spriteBatch.Begin();

            spriteBatch.Draw(_bakgrundbtntxt, _bakgrundbtnpos, Color.White);
            spriteBatch.Draw(_startaspelettexture, _startaspeletpos, Color.Black);
            spriteBatch.Draw(_insttexture, _instpos, Color.Black);
            spriteBatch.Draw(_highscoretexture, _highscorepos, Color.Black);
            spriteBatch.Draw(_avslutaspeltexture, _avslutaspelpos, Color.Black);

            spriteBatch.End();


        }



        public bool GameStart(SpriteBatch spriteBatch) // This one checks that the mouse is in the position where picture Starta Spel is.
        {
            Vector2 musposition = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
            //  Texture2D mustexture = new Texture2D(Mouse.GetState().
            if (Mouse.GetState().X > _startaspeletpos.X && Mouse.GetState().X < _startaspeletpos.X + _startaspelettexture.Width)
            {
                if (Mouse.GetState().Y > _startaspeletpos.Y && Mouse.GetState().Y < _startaspeletpos.Y + _startaspelettexture.Height)
                {
                    if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                    {
                        return true; // Returns true if mouse is clicked in Starta Spel area
                    }
                    return false;
                }
                return false;
            }
            return false;
        }        // Returns false if mouse click is not clicked in Starta Spel area.

        /// <summary>
        /// Method for quit the game.
        /// </summary>
        /// <param name="spriteBatch"></param>
        /// <returns></returns>
        public bool GameEnd(SpriteBatch spriteBatch) //method to quit game
        {
            Vector2 musposition = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); //
            if (Mouse.GetState().X > _avslutaspelpos.X && Mouse.GetState().X < _avslutaspelpos.X + _avslutaspeltexture.Width)
            {
                if (Mouse.GetState().Y > _avslutaspelpos.Y && Mouse.GetState().Y < _avslutaspelpos.Y + _avslutaspeltexture.Height)
                {
                    if(Mouse.GetState().LeftButton == ButtonState.Pressed)
                    {

                        return true;
                    }
                    return false;
                }

                return false;
            }
            return false;
        }
            public bool instruktioner(SpriteBatch spriteBatch)// method that will se if the mouse is at instruktion at the main menu 
            {
                if (Mouse.GetState().X > _instpos.X && Mouse.GetState().X < _instpos.X + _insttexture.Width)
                {
                    if (Mouse.GetState().Y > _startaspeletpos.Y && Mouse.GetState().Y < _instpos.Y + _insttexture.Height)
                        {
                            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                        {
                        return true;
                }
                    return false;
              }
                return false;
            }
            return false;
        }
            public void ritainstrukt(SpriteBatch spriteBatch, Texture2D _instruktion) //draws the instruktion picture
            {
                spriteBatch.Begin();
                spriteBatch.Draw(_instruktion, new Vector2(50, 50), Color.White);
                spriteBatch.End();


            }



    }
    }

